from tortoise import Tortoise
from tortoise_config import TORTOISE_ORM

async def connect_db():
    await Tortoise.init(config=TORTOISE_ORM)
    #将model的表结构更新给数据库
    #await Tortoise.generate_schemas()

async def disconnect_db():
    await Tortoise.close_connections()


#执行原生Sql
async def execute_raw_sql_dict(sql: str):
    results = await Tortoise.get_connection('default').execute_query_dict(sql)
    return results

